/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package upeu.cepre.business;

import com.mysql.jdbc.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import upeu.cepre.model.Carrera;
import upeu.cepre.util.DataBaseConexion;

public class CarreraManager {
    
    Carrera to = new Carrera();
    private Connection connection;

//    public Lis<> Report() {
//    }
//
//    public void Insert() {
//    }
//
//    public void Update() {
//    }
//
//    public void Delete() {
//    }

    /*
     * Metodos Complementarios
     */
    public Carrera FindId(String IdCarrera) {
        try {
            connection = (Connection) DataBaseConexion.getConexion();
            Statement statement = connection.createStatement();
            PreparedStatement prepareestatemente = connection.prepareStatement("SELECT * From carrera WHERE idCarrera=?  ");
            prepareestatemente.setString(1, IdCarrera);
            ResultSet rs = prepareestatemente.executeQuery();
            
            if (rs.next()) {
                
               
                to.setIdCarrera(rs.getString("idCarrera"));
                to.setNombre(rs.getString("nombre"));
                to.setDescripcion(rs.getString("descripcion"));
                to.setFacultad(rs.getString("facultad"));
                
                
            }
            connection.close();
            statement.close();
            prepareestatemente.close();
            rs.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return to;
    }
//    public void ObtenerId() {
//    }
}
